package com.zhen.aikan.config;

import com.zhen.aikan.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 错误统一处理器
 * @author LiJiaZhen
 * @date 2023/9/19 23:46
 */
@Slf4j
@RestControllerAdvice
public class WebExceptionAdvice {
    private final Logger logger = LoggerFactory.getLogger(WebExceptionAdvice.class);
    @ExceptionHandler(RuntimeException.class)
    public Result handleRuntimeException(RuntimeException e) {
        logger.error("服务器错误:{}",e);
        return Result.fail("服务器错误");
    }
}
